/*
 * SplittingTreeNodeTest.cpp
 *
 * Copyright 2012 Fabian Wenzelmann
 *
 * This file is part of Recognition-Procedures-for-Boolean-Functions.
 *
 * Recognition-Procedures-for-Boolean-Functions is free software: you
 * can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * Recognition-Procedures-for-Boolean-Functions is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Recognition-Procedures-for-Boolean-Functions.
 *
 * If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <fstream>

#include <gtest/gtest.h>

#include "bfr/Clause.hpp"
#include "bfr/ClauseSet.hpp"

#include "bfr/lpbCombinatorial/MainNode.hpp"
#include "bfr/lpbCombinatorial/VariableSetting.hpp"
#include "bfr/lpbCombinatorial/TreeContext.hpp"
#include "bfr/DIMACSParser.hpp"

namespace bfr { namespace test {

TEST(SplittingTreeNode, splitAway1) {
	ClauseSet *cs = new ClauseSet();

	Clause *c1 = new Clause(1);
	c1->addSecure(new Literal(0));

	Clause *c2 = new Clause(2);
	c2->addSecure(new Literal(1));
	c2->addSecure(new Literal(2));

	cs->addSecure(c1);
	cs->addSecure(c2);

	VariableSetting vs = VariableSetting(cs);

	TreeContext *context = new TreeContext(3);

	MainNode *n = new MainNode(NULL, NULL, cs, vs.getOrderedPatterns(), context);

	n->split(&vs);

	ASSERT_FALSE(n->getLowerChild() == NULL);
	ASSERT_FALSE(n->getUpperChild() == NULL);

	ClauseSet *result1 = new ClauseSet(1);
	Clause *result11 = new Clause(2);
	result11->addSecure(new Literal(1));
	result11->addSecure(new Literal(2));
	result1->addSecure(result11);

	ClauseSet *result2 = new ClauseSet(1);
	Clause *result21 = new Clause(0);
	result2->addSecure(result21);

	EXPECT_EQ(*result1, *(n->getUpperChild()->getDNF()));
	EXPECT_EQ(*result2, *(n->getLowerChild()->getDNF()));

	delete n->getUpperChild();
	delete n->getLowerChild();
	delete n;
	delete context;
	delete result1;
	delete result2;
}

TEST(SplittingTreeNode, splitAway2) {

}

}}
